<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    class People {
      constructor(name = 'tom', age = '27') {
        this.name = name
        this.age = age
      }
      eat () {
        console.log(`${this.name}今年${this.age}岁,正在 eat food`);
      }
    }

    // 继承父类
    class Woman extends People {
      constructor(name = 'ren', age = '25', sex) {
        // 继承父类属性
        super(name, age)
        this.sex = sex
      }
      eat () {
        // 继承父类方法
        super.eat()
        console.log('子类单独加的功能');
      }
      say () {
        console.log('子类中的说话');
      }
    }

    let p = new People()
    // console.log(p);
    p.eat()
    let wo = new Woman('amy', '16', 'girl')
    // console.log(wo);
    wo.eat()
    wo.say()
  </script>
</body>

</html>